package com.njit.farm.controller;

import com.njit.farm.model.Opreation;
import com.njit.farm.model.Result;
import com.njit.farm.service.OpreationService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/opreation/")
public class OpreationController {

    @Resource
    OpreationService opreationService;

    @RequestMapping(value = "add", method = RequestMethod.POST)
    public Result add(@RequestBody Opreation opreation, @RequestParam("lId") String lId) {
        return opreationService.add(lId, opreation);
    }

    @RequestMapping(value = "getByLandId", method = RequestMethod.GET)
    public Result getByLandId(@RequestParam("lId") String lId) {
        return opreationService.queryByLandId(lId);
    }

    @RequestMapping(value = "update", method = RequestMethod.POST)
    public Result update(@RequestBody Opreation opreation) {

        return opreationService.update(opreation);
    }
}
